<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body><span>字符串 (1 2 3)</span>
<input type="text" value="1,2" id="text1">&nbsp;
<span>要查找的元素</span>
<input type="text" value="1,2,3,4,1" id="text2">&nbsp;
<input type="button" value="开始查找" onclick="chaZhao()">

</body>

<script>
    var elementById1 = document.getElementById("text1");
    var elementById2 = document.getElementById("text2");

    function chaZhao() {

        var arr1 = elementById1.value.split(",");
        var arr2 = elementById2.value.split(",");
        var str1 = "";
        var str2 = "";

        for (var i = 0; i < arr1.length; i++) {
            str1 += arr1[i];
        }
        for (var i = 0; i < arr2.length; i++) {
            str2 += arr2[i];
        }
        var indix = -1;

        alert(str2.indexOf(str1)+1)

    }
</script>
</html>